package com.sicheng.lc.周赛.分类.二分or排序;

import java.util.Arrays;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/19 18:30
 */
public class 统计包含每个点的矩形数目 {
    //    https://leetcode.cn/problems/count-number-of-rectangles-containing-each-point/
    public int[] countRectangles(int[][] rectangles, int[][] points) {
        int[] count = new int[points.length];
        int index = 0;
        Arrays.sort(rectangles, (k1, k2) -> k1[0] == k2[0] ? k1[1] - k2[1] : k1[0] - k2[0]);
        for (int[] point : points) {
            int x = point[0];
            int y = point[1];
            int i = binarySearch(rectangles, x);
            if (i >= 0) {

            }
            index++;
        }

        return count;
    }

    int binarySearch(int[][] rectangles, int x) {
        if (x > rectangles[rectangles.length - 1][0]) return -1;
        int l = 0, r = rectangles.length - 1;
        while (l < r) {
            int mid = r + l >> 1;
            if (rectangles[mid][0] >= x) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        return l;
    }

    public static void main(String[] args) {
        统计包含每个点的矩形数目 solution = new 统计包含每个点的矩形数目();

    }
}
